package pk;
import  gdb.mydatabase;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class dgdetails 
{
	public static String getdgdetails()
	{
		int a=0,b=0;
		String msg=null;
		Connection con=null;
		try
		{
			con=mydatabase.mydbcon();
			PreparedStatement ps=con.prepareStatement("select count(*) from  dept_details");
			ResultSet rs=ps.executeQuery();
			while(rs.next())
			{
				a=rs.getInt(1);
			}
		}
		catch(Exception e)
		{
			System.out.println("myerr"+e);
		}
		try
		{
			con=mydatabase.mydbcon();
			PreparedStatement ps=con.prepareStatement("select count(*) from dg_user_detail where dg_user_id=(select dg_user_id from dg_login_details where status='1') and dg_user_id=(select dg_user_id from dg_incumbancy_details where inc_date=(select max(inc_date) from dg_incumbancy_details))");
			ResultSet rs=ps.executeQuery();
			while(rs.next())
			{
				b=rs.getInt(1);
			}
			
		}
		catch(Exception e)
		{
			System.out.println("myerr1"+e);
		}
		if((a==0)&&(b==0))
		{
			msg="fresh";
		}
		else if((a==1)&&(b==1))
		{
			msg="present";
		}
		else
		{
			msg="database error";
		}
		return msg;
	}

}
